package models;

import java.io.FileNotFoundException;
import java.io.IOException;

import javax.xml.parsers.ParserConfigurationException;

import org.xml.sax.SAXException;

import objects.Constituent;

/* Reads from and Writes to XML files */
public class SemRepModel {
	
	/* static constituent variable to remove need for creating SemRepModel objects */
	private static Constituent constituent;
	
	public SemRepModel() {}
	
	public static void read() throws ParserConfigurationException, SAXException, IOException {
		SemRepXMLReader reader = new SemRepXMLReader();
		reader.read(SemRepFileModel.getFile());
		constituent = reader.getConstituent();
	}
	
	public static void write() throws FileNotFoundException, IOException {
		SemRepXMLWriter writer = new SemRepXMLWriter();
		writer.setConstituent(constituent);
		writer.write(SemRepFileModel.getFile());
	}
	
	/** Get/Set data **/
	
	public static void setConstituent(Constituent newConstituent) {
		constituent = newConstituent;
	}
	
	public static Constituent getConstituent() {
		return constituent;
	}
	
}
